<?php

namespace app\common\model;

use think\Model;

/**
 * Payment
 */
class Payment extends Model
{
    // 表名
    protected $name = 'payment';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;
    // 下拉框:0=未支付,1=支付成功,2=支付失败
    const PAY_STATUS = [
        0 => '未支付',
        1 => '支付成功',
        2 => '支付失败',
    ];
    const PAY_STATUS_UNPAY = 0;
    const PAY_STATUS_PAID = 1;
    const PAY_STATUS_FAILED  = 2;
    // /支付方式，alipay,wxpay等
    const PAYMENT_METHOD = [
        'wechat' => '微信',
        'alipay' => '支付宝',
    ];
    const PAYMENT_METHOD_WECHAT = 'wechat';
    const PAYMENT_METHOD_ALIPAY = 'alipay';

    public function getAmountAttr($value): ?float
    {
        return is_null($value) ? null : (float)$value;
    }
}
